import 'package:flutter/material.dart';

class StatefulWidgetAndStatelessWidget extends StatefulWidget {
  StatefulWidgetAndStatelessWidget({Key key}) : super(key: key);

  @override
  _StatefulWidgetAndStatelessWidgetState createState() =>
      _StatefulWidgetAndStatelessWidgetState();
}

class _StatefulWidgetAndStatelessWidgetState
    extends State<StatefulWidgetAndStatelessWidget> {
  @override
  Widget build(BuildContext context) {
    print('StatefulWidgetAndStatelessWidget');
    return Scaffold(
      appBar: AppBar(
        title: Text('StatefulWidgetAndStatelessWidget'),
      ),
      body: Container(
        child: Column(
          children: <Widget>[
            StatefullTestWidet(),
            StateLessTestWidet(),
            FlatButton(
              child: Text('返回'),
              onPressed: () {
                Navigator.of(context).pop('zsk');
              },
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        child: Text('按钮'),
        onPressed: () {
          setState(() {});
        },
      ),
    );
  }
}

class StateLessTestWidet extends StatelessWidget {
  const StateLessTestWidet({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    print('StateLessTestWidet');
    return Container(
      padding: EdgeInsets.all(20.0),
      color: Colors.pinkAccent,
      child: Text('StateLessTestWidet'),
    );
  }
}

class StatefullTestWidet extends StatefulWidget {
  StatefullTestWidet({Key key}) : super(key: key);

  @override
  _StatefullTestWidetState createState() => _StatefullTestWidetState();
}

class _StatefullTestWidetState extends State<StatefullTestWidet> {
  @override
  Widget build(BuildContext context) {
    print('StatefullTestWidet');
    return Container(
      padding: EdgeInsets.all(20.0),
      color: Colors.red,
      child: Text('StatefullTestWidet'),
    );
  }
}
